<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="../include/laypublic.jsp" %>
<!DOCTYPE html>
<html>
<head>
</head>
<title>营销奖励</title>
<style type="text/css">
    .layui-form-select dl {
        max-height: 150px;
    / / 原值为300，调节高度建议为50的倍数
    }

    .layui-form-label {
        width: 80px;
    }
</style>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <!-- 查询区域  -->
        <div id="query-form" class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">项目ID</label>
                    <div class="layui-input-inline">
                        <input type="text" name="proCode" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">项目名称</label>
                    <div class="layui-input-inline">
                        <input type="text" name="proName" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">区域公司</label>
                    <div class="layui-input-inline">
                        <select name="hrOrgId">
                            <option value="">全部</option>
                            <c:if test="${not empty orgInfoList }">
                                <c:forEach items="${orgInfoList}" var="orgInfo">
                                    <option value="${orgInfo.id}">${orgInfo.compName }</option>
                                </c:forEach>
                            </c:if>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">状态</label>
                    <div class="layui-input-inline">
                        <select name="processStatus">
                            <option value="">请选择</option>
                            <option value="1">审批中</option>
                            <option value="9">审批完成</option>
                            <option value="10">审批终止</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">创建日期</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" id="sent-laydate-start" name="startDate" readonly
                               placeholder="开始日期">
                    </div>
                    <div class="layui-form-mid">
                        -
                    </div>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" id="sent-laydate-end" name="endDate" readonly
                               placeholder="结束日期">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">营销经理</label>
                    <div class="layui-input-inline">
                        <select name="staffId">
                            <option value="">全部</option>
                            <c:if test="${not empty staffInfoList }">
                                <c:forEach items="${staffInfoList}" var="staffInfo">
                                    <option value="${staffInfo.id}">${staffInfo.staffName }</option>
                                </c:forEach>
                            </c:if>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">申请奖金金额</label>
                    <div class="layui-input-inline" style="width:100px">
                        <input type="text" class="layui-input" name="sumAmountMin" placeholder="￥" autocomplete="off">
                    </div>
                    <div class="layui-form-mid">
                        -
                    </div>
                    <div class="layui-input-inline" style="width:100px">
                        <input type="text" class="layui-input" name="sumAmountMax" placeholder="￥" autocomplete="off">
                    </div>
                </div>
                <div class="layui-inline">
                    <button class="layui-btn layuiadmin-btn-admin" lay-submit lay-filter="LAY-marketingReward-search">
                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>查询
                    </button>
                    <button class="layui-btn layuiadmin-btn-admin" lay-submit lay-filter="LAY-user-back-reset">
                        <i class="layui-icon layui-icon-fonts-clear  layuiadmin-button-btn"></i>重置
                    </button>
                    <button class="layui-btn layuiadmin-btn-admin " data-type="add">
                        <i class="layui-icon layui-icon-add-1 layuiadmin-button-btn"></i>新建
                    </button>
                    <button class="layui-btn layuiadmin-btn-admin" data-type="export" onclick="exportList();">
                        <i class="layui-icon layui-icon-export layuiadmin-button-btn"></i>导出
                    </button>
                </div>
            </div>
        </div>
        <!-- 按钮区域  -->
        <div class="layui-card-body">
            <div class="layui-tab-item layui-show">
                <table id="LAY-marketingReward-create-manage" lay-filter="LAY-marketingReward-create-manage"></table>
            </div>
        </div>
    </div>
</div>

<script>
    layui.config({
        base: '${ctx}/resources/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table', 'set', 'transfer', 'laydate'], function () {
        var $ = layui.$
            , form = layui.form
            , table = layui.table
            , element = layui.element
            , laydate = layui.laydate;
        //tab重新渲染宽度
        element.on('tab(component-tabs-brief)', function (obj) {
            $(window).resize();
        });

        //开始日期
        var insStart = laydate.render({
            elem: '#sent-laydate-start'
            , done: function (value, date) {
                //更新结束日期的最小日期
                insEnd.config.min = lay.extend({}, date, {
                    month: date.month - 1
                });

                //自动弹出结束日期的选择器
                insEnd.config.elem[0].focus();
            }
        });

        //结束日期
        var insEnd = laydate.render({
            elem: '#sent-laydate-end'
            , done: function (value, date) {
                //更新开始日期的最大日期
                insStart.config.max = lay.extend({}, date, {
                    month: date.month - 1
                });
            }
        });
        // 正则校验
        form.verify({
            //验证汉字
            CHS: [
                /^[\u0391-\uFFE5]+$/
                , '只能输入汉字'
            ],
            //大于0的正整数
            intNumber: [
                /^[1-9]\d*$/
                , '请输入正确的数字'
            ]
        });

        // 表单
        table.render({
            elem: '#LAY-marketingReward-create-manage'
            ,
            url: basePath + '/saleReward/queryDataByCondition?step=1&hrStaffApplyId=${SESSION_KEY_USER_DETAIL.hrStaffId }' //请求数据接口
            ,
            cols: [[
                {type: 'checkbox', fixed: 'left'}
                , {field: 'proCode', title: '项目ID', width: 130}
                , {field: 'proName', title: '项目名称'}
                , {field: 'sgCityName', title: '项目城市', width: 150}
                , {
                    field: 'addTime', title: '创建时间', width: 160, templet: function (d) {
                        return layui.util.toDateString(d.addTime, "yyyy-MM-dd HH:mm:ss");
                    }
                }
                , {field: 'hrStaffName', title: '营销经理', width: 100}
                , {
                    field: 'rewardAmount', title: '申请奖金金额', width: 120, templet: function (d) {
                        return formatCurrency(d.rewardAmount);
                    }
                }
                , {
                    title: '操作', width: 130, align: 'center', fixed: 'right', templet: function (d) {
                        var optStr = "";
                        <shiro:hasPermission name="VIEW_MARKETING_REWARD">
                        optStr += '<a class="layui-btn layui-btn-xs" lay-event="view"><i class="layui-icon layui-icon-form"></i>详情</a>';
                        </shiro:hasPermission>
                        return optStr;
                    }
                }
            ]]
            ,
            page: true
            ,
            limit: 10
        });

        //监听搜索
        form.on('submit(LAY-marketingReward-search)', function (data) {
            table.reload('LAY-marketingReward-create-manage', {
                page: {curr: 1},
                where: trimData(data)
            });
        });
        //重置清空
        form.on('submit(LAY-user-back-reset)', function (data) {
            reset_form('query-form');
            //额外处理select
            $("#query-form-state").val('');
            form.render();
        });

        // 监听操作列
        table.on('tool(LAY-marketingReward-create-manage)', function (obj) {
            var data = obj.data;
            if (obj.event === 'view') {//查看详情
                parent.layui.index.openTabsPage(basePath + '/saleReward/toDealOrDetail?id=' + data.id + '&proCode=' + data.proCode, '营销奖励 > 详情');
            } else if (obj.event === 'copy') {//复制单据
                parent.layui.index.openTabsPage(basePath + '/marketingReward/toCopy?id=' + data.id, '营销奖励 > 复制单据');
            } else if (obj.event === 'del') {
                layer.confirm('确定要删除？', {icon: 3, title: '提示'}, function (index) {
                    $.ajax({
                        type: 'post',
                        url: basePath + '/flowProcess/logicDel',
                        data: {
                            "processId": data.processId
                        },//数据，这里使用的是Json格式进行传输
                        success: function (result) {
                            if (result) {
                                table.reload('LAY-marketingReward-create-manage'); //数据刷新
                                layer.close(index); //关闭弹层
                            } else {
                                layer.msg('数据通信异常~', {icon: 0});
                            }
                        }
                    });
                })
            }
        });

        // 监听操作列
        table.on('tool(LAY-marketingReward-wait-manage)', function (obj) {
            var data = obj.data;
            if (obj.event === 'view') {
                parent.layui.index.openTabsPage(basePath + '/marketingReward/toDealOrDetail?id=' + data.id, '营销奖励 > 详情');
            }
        });

        // 按钮事件
        var active = {
            add: function () {
                console.log(11111);
                parent.layui.index.openTabsPage(basePath + '/saleReward/toDealOrDetail?id=' + '', '营销奖励 > 新建');
            }
        }
        // data-type事件
        $('.layui-btn.layuiadmin-btn-admin').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

    });

    //导出excel
    function exportList() {
        layer.msg("暂未上线，敬请期待~", {icon: 1});
        /*var $ = layui.$;
        var params = "?proCode=";
        params += $('#queryProCode').val().trim();
        params += "&startDate=";
        params += $('#sent-laydate-start').val().trim();
        params += "&endDate=";
        params += $('#sent-laydate-end').val().trim();
        params += "&customerName=";
        params += $('#queryCustomerName').val().trim();
        params += "&mobile=";
        params += $('#queryMobile').val().trim();
        params += "&provinceName=";
        params += $('#queryProvinceName').val().trim();
        params += "&cityName=";
        params += $('#queryCityName').val().trim();
        params += "&state=";
        params += $('#queryState').val().trim();
        window.location.href = "


        ${ctx}/marketingReward/exportToExcel"+params;*/
    }
</script>
</body>
</html>

